"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/3/17 13:55
@Description : 

"""
from threading import Thread
import time

count = 0

def add_count():
    global count
    for i in range(5):
        count += 1
        time.sleep(0.2)
        print('add = ', count)


def sub_count():
    # thread1.join()
    global count
    for i in range(5):
        count -= 1
        time.sleep(0.2)
        print('sub = ', count)


# 创建线程  并发执行
thread1 = Thread(target=add_count)
thread2 = Thread(target=sub_count)

# 开启线程
thread1.start()
# MainThread等待thread1执行结束 在向下执行
# thread1.join()
print('----------------------------')
thread2.start()
